//
//  QuDanCenterAlterView.m
//  QuDanOEM
//
//  Created by xiaohuang on 2021/11/7.
//

#import "QuDanCenterAlterView.h"

@interface QuDanCenterAlterView ()

@end

@implementation QuDanCenterAlterView

+ (instancetype)alertView
{
    QuDanCenterAlterView *aView = [[[NSBundle mainBundle] loadNibNamed:@"QuDanCenterAlterView" owner:self options:nil] lastObject];
    NSCParameterAssert(aView);
    aView.frame = [UIScreen mainScreen].bounds;
    aView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
    aView.bgView.layer.cornerRadius = 8.0f;
    aView.bgView.layer.masksToBounds = YES;
    return aView;
}
- (void)show
{
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    NSCParameterAssert(window);
    [window addSubview:self];
    self.alpha = 0;
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 1;
    }];
}
- (void)dismiss
{
    [UIView animateWithDuration:0.3 animations:^{
        self.alpha = 0;
    } completion:^(BOOL finished) {
        self.hidden = YES;
        [self removeFromSuperview];
    }];
}
/// 发布技能btn
/// @param sender 发布技能btn
- (IBAction)actionSendSkillBtn:(UIButton *)sender
{
    if (self.QuDanCenterAlterViewSkillBlock) {
        self.QuDanCenterAlterViewSkillBlock();
    }
    [self dismiss];
}
/// 发布动态btn
/// @param sender 发布动态btn
- (IBAction)actionSendDongtaiBtn:(UIButton *)sender
{
    if (self.QuDanCenterAlterViewDongtaiBlock) {
        self.QuDanCenterAlterViewDongtaiBlock();
    }
    [self dismiss];
}

/// 取消
/// @param sender 取消
- (IBAction)actionCancelBtn:(UIButton *)sender
{
    [self dismiss];
}
@end
